/*
 * User: Sepheus Angelus
 * Date: 08/03/2008
 * Time: 12:03
 * 
 */

using System;
using IronPython.Hosting;
using IronPython.Runtime;

namespace Aphyros_MUD_Server
{
	/// <summary>
	/// Description of ScriptEngine.
	/// </summary>
	public class ScriptEngine
	{
		
		/// <summary>
		/// The engine accessor.
		/// </summary>
		public static PythonEngine engine;
		
		/// <summary>
		/// Parses the script attached to an item or skill.
		/// </summary>
		/// <param name="Script">The script string.</param>
		public static void Parse(string Script)
		{
		}
		
		/// <summary>
		/// Initialize the Python engine and expose classes.
		/// </summary>
		public static void Initialize()
		{
			engine = new PythonEngine();
			Skills skills = new Skills();
			Classes classes = new Classes();
			ANSI ansi = new ANSI();
			Rooms rooms = new Rooms();
			engine.AddToPath(Environment.CurrentDirectory);
			engine.Globals.Add("Skills",skills);
			engine.Globals.Add("Classes",classes);
			engine.Globals.Add("Colour",ansi);
			engine.Globals.Add("Rooms",rooms);
			Console.ForegroundColor = ConsoleColor.Cyan;
			Console.WriteLine("Loaded Scripting Engine.");
		}
		
		/// <summary>
		/// Reloads the Python scripting engine.
		/// </summary>
		public static void Reload()
		{
			Console.ForegroundColor = ConsoleColor.Green;
			Console.WriteLine("Reloading Scripting Engine...");
			engine.Dispose();
			Initialize();
		}
		
	}
}
